/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-09-17
 * Time:22:57
 */
public class Java_1 {
    public static int[] twoSum(int[] nums, int target) {
        int[] arr = new int[2];
        int i = 0;
        while ( i< nums.length - 1&&  nums[i] <= target) {
            int j = i + 1;
            while ( j < nums.length&& nums[j] <= target) {
                if (nums[i] + nums[j] == target) {
                    arr[0] = nums[i];
                    arr[1] = nums[j];
                    return arr;
                }
                j++;
            }
            i++;
        }
        return null;
    }
    public static int[] twoSum1(int[] nums, int target) {
        int[] arr = new int[2];
        int right = nums.length-1,left=0;
        while(left<right)
        {
            if(nums[right]+nums[left]<target)
            {
                left++;
            }
            else if(nums[right]+nums[left]>target)
            {
                right--;
            }
            else {
                arr[0]=nums[left];
                arr[1]=nums[right];
                return arr;
            }
        }
        return null;

    }
    public static void main(String[] args) {
        int[] array={14,15,16,22,53,60};
        twoSum(array,76);
    }
}
